﻿using System;
using System.Collections.Generic;
using System.Text;
using VCDIFF.Visit;

namespace VCDIFF.Commands
{
    ///<summary>
    /// NOOP: NOOP means that no instruction is specified. It fills the instruction table when
    /// only one RUN, ADD or COPY is used.
    ///</summary>
    public class Noop : Command
    {
        /// <summary>
        /// Noop constructor.
        /// </summary>
        public Noop()
        {

        }

        /// <summary>
        /// Returns the encoded byte table of the Noop command.
        /// </summary>
        /// <returns>The encoded byte table of the Noop command.</returns>
        public override byte[] ToByteArray()
        {
            byte[] noopArray = new byte[1] { 0x00 };

            return noopArray;
        }

        /// <summary>
        /// Returns the encoded byte table of the Noop command.
        /// </summary>
        /// <param name="target">The byte table where the Noop command proceded.</param>
        /// <returns>The encoded byte table of the Noop command.</returns>
        public override byte[] Execute(byte[] target)
        {
            return target;
        }

        /// <summary>
        /// Writes Noop command thanks to a Writer.
        /// </summary>
        /// <param name="writer">Writer who writes Noop command.</param>
        public override void Write(Writer writer)
        {
            writer.Visit(this);
        }

        /// <summary>
        /// Accepts a reader and authorizes it to visit this object.
        /// </summary>
        /// <param name="writer">Reader which visits this object.</param>
        public override void Read(Reader reader)
        {
            reader.Visit(this);
        }
    }
}
